//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.xxxy.jsq.action.rule;

import com.xxxy.jsq.dao.RuleDao;
import com.xxxy.jsq.model.Rule;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet({"/updateRuleServlet"})
public class updateRuleServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    public updateRuleServlet() {
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        Rule model = new Rule();
        RuleDao dao = new RuleDao();
        String ruleFlag = request.getParameter("ruleFlag");
        String ruleName = request.getParameter("cname");
        String levelId = request.getParameter("levelId");
        String worksId = request.getParameter("worksId");
        String ruleCount = request.getParameter("ruleCount");
        String ruleYears = request.getParameter("ruleYears");
        String ruleMemo = request.getParameter("ruleMemo");
        Long ruleId = Long.valueOf(request.getParameter("cid"));
        if (ruleFlag != null && !ruleFlag.equals("")) {
            model.setRuleFlag(ruleFlag);
        }

        if (levelId != null && !levelId.equals("")) {
            model.setLevelId(Long.valueOf(levelId));
        }

        if (worksId != null && !worksId.equals("")) {
            model.setWorksId(Long.valueOf(worksId));
        }

        if (ruleCount != null && !ruleCount.equals("")) {
            model.setRuleCount(Integer.parseInt(ruleCount));
        }

        if (ruleYears != null && !ruleYears.equals("")) {
            model.setRuleYears(Integer.parseInt(ruleYears));
        }

        if (ruleMemo != null && !ruleMemo.equals("")) {
            model.setRuleMemo(ruleMemo);
        }

        model.setRuleId(ruleId);
        String str = dao.update(model);
        PrintWriter out = response.getWriter();
        out.print(str);
        out.flush();
        out.close();
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}



